//logs.js

const app = getApp()
import {
  HomeIndex
} from 'index-modal.js';
import {
  Config
} from '../../../utils/config.js';
var Function = require("../../../utils/function.js");
var index = new HomeIndex(); //实例化 首页 对象

let Charts = require('../../../utils/wxcharts.js');
var lineChart;
Page({
  data: {
    url:Config.Url,
    id:'',
    info:null,
    is_huo:true,
    detaile:{}
  },
  onLoad: function (options) {
    this.setData({id:options.id});
    this._getDetail();
    this.creatCavas();
  },
 
  _getDetail(){   //获取门店详情
    let that =this;
    let data ={
      id:that.data.id
    }
    index.getDetail(data,(res)=>{
       if(res.code == 200){
        that.setData({
          detaile:res.data
        })
       }
    })
  },

  creatCavas(){                //canvas
    let that = this
    var myDate = new Date();
    var date = myDate.toLocaleDateString();
    
    that.setData({
      date: date,  //选择时间
    })
    var windowWidth = '', windowHeight = '';    //定义宽高
    try {
      var res = wx.getSystemInfoSync();    //试图获取屏幕宽高数据
      windowWidth = res.windowWidth / 750 * 700   
      windowHeight = res.windowWidth / 750 * 500   
    } catch (e) {
      console.error('getSystemInfoSync failed!');  
    }

    lineChart = new Charts({
      canvasId: 'lineCanvas',
      type: 'line',
      animation: true,  //是否开启动画
      categories: ['9:00', '11:00', '13:00', '15:00', '17:00', '19:00', '21:00','23:00'],
      series: [
        {
        name: '周末',
        data: [1,18,30,66,44,77,100,20],
        format: function (val) {
          return '';
        }
        },{
          name: '工作日',
          data: [11,88,30,5,66,19,24,39],
          format: function (val) {
            return '';
          }
          }
      ],
      xAxis: {   //是否隐藏x轴分割线
        disableGrid: true,
      },
      yAxis: {
      
        format: function (val) {
        
          return val.toFixed(2);
        },
      },
      width: windowWidth, //图表展示内容宽度
      height: windowHeight, //图表展示内容高度
      dataLabel: true,    //是否在图表上直接显示数据
      dataPointShape: true, //是否在图标上显示数据点标志
      extra: {
        lineStyle: 'curve'  //曲线
      },
    });

    // lineChart()
  },
  touchHandler: function (e) {
    // lineChart.showToolTip(e, {
    //   // background: '#7cb5ec',
    //   format: function (item, category) {
    //     return category + ' ' + item.name + ':' + item.data
    //   }
    // });
  },
  checkis_huo(){ 
    this.setData({
      is_huo:!this.data.is_huo
    })
  },
  penmap(e) {
    let lng = parseInt(e.currentTarget.dataset.lng);
    let lag = parseInt(e.currentTarget.dataset.lag);
    let that = this;
    wx.openLocation({
      latitude: lag,
      longitude: lng,
      scale:15,
      name: that.data.detaile.address,
      success: function () { }
    })
  },
})
